package com.hq.door.dto;

import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.List;

import com.hq.door.pojo.TOutRequest;
import com.hq.door.pojo.TStudent;

public class OutrequestInfo {
	private Integer id;
	private String majorname;
	private String classname;
	private String studentname;
	private Timestamp startTime;
	private Timestamp endTime;
	private String teachername;
	private String requestReason;
	private String rejectReason;
	private Integer authStatus;
	private Timestamp requestTime;

	public OutrequestInfo() {
		// TODO Auto-generated constructor stub
	}

	public OutrequestInfo(Integer id, String majorname, String classname,
			String studentname, Timestamp startTime, Timestamp endTime,
			String teachername, String requestReason, String rejectReason, Integer authStatus) {
		super();
		this.id = id;
		this.majorname = majorname;
		this.classname = classname;
		this.studentname = studentname;
		this.startTime = startTime;
		this.endTime = endTime;
		this.teachername = teachername;
		this.requestReason = requestReason;
		this.rejectReason = rejectReason;
		this.authStatus = authStatus;
	}

	public String getRejectReason() {
		return rejectReason;
	}

	public void setRejectReason(String rejectReason) {
		this.rejectReason = rejectReason;
	}

	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public String getMajorname() {
		return majorname;
	}

	public void setMajorname(String majorname) {
		this.majorname = majorname;
	}

	public String getClassname() {
		return classname;
	}

	public void setClassname(String classname) {
		this.classname = classname;
	}

	public String getTeachername() {
		return teachername;
	}

	public void setTeachername(String teachername) {
		this.teachername = teachername;
	}

	public String getStudentname() {
		return studentname;
	}

	public void setStudentname(String studentname) {
		this.studentname = studentname;
	}

	public Timestamp getStartTime() {
		return startTime;
	}

	public void setStartTime(Timestamp startTime) {
		this.startTime = startTime;
	}

	public Timestamp getEndTime() {
		return endTime;
	}

	public void setEndTime(Timestamp endTime) {
		this.endTime = endTime;
	}

	public String getRequestReason() {
		return requestReason;
	}

	public void setRequestReason(String requestReason) {
		this.requestReason = requestReason;
	}

	public Integer getAuthStatus() {
		return authStatus;
	}

	public void setAuthStatus(Integer authStatus) {
		this.authStatus = authStatus;
	}

	public Timestamp getRequestTime() {
		return requestTime;
	}

	public void setRequestTime(Timestamp requestTime) {
		this.requestTime = requestTime;
	}

	@Override
	public String toString() {
		return "OutrequestInfo [id=" + id + ", majorname=" + majorname
				+ ", classname=" + classname + ", studentname=" + studentname
				+ ", startTime=" + startTime + ", endTime=" + endTime
				+ ", teachername=" + teachername + ", requestReason="
				+ requestReason + ", rejectReason=" + rejectReason
				+ ", authStatus=" + authStatus + ", requestTime=" + requestTime
				+ "]";
	}

	public void getRequestInfo(TOutRequest tOutRequest) {
		this.id = tOutRequest.getId();

		if (tOutRequest.getTStudent().getTClass() != null) {
			this.classname = tOutRequest.getTStudent().getTClass().getName();
		}
		if (tOutRequest.getTStudent().getTClass().getTMajor() != null) {
			this.majorname = tOutRequest.getTStudent().getTClass().getTMajor()
					.getName();
		}
		if (tOutRequest.getTStudent() != null) {
			this.studentname = tOutRequest.getTStudent().getName();
		}
		this.startTime = tOutRequest.getStartTime();
		this.endTime = tOutRequest.getEndTime();
		this.requestTime = tOutRequest.getRequestTime();
		if (tOutRequest.getTTeacher() != null)
			this.teachername = tOutRequest.getTTeacher().getName();
		this.requestReason = tOutRequest.getRequestReason();
		if(tOutRequest.getRejectReason()!=null)
			this.rejectReason = tOutRequest.getRejectReason();
		this.authStatus = tOutRequest.getAuthStatus();
	}

	public List<OutrequestInfo> getTOutrequest(List<TOutRequest> tOutRequests) {
		List<OutrequestInfo> outrequestInfos = new ArrayList<OutrequestInfo>();
		for (TOutRequest tOutRequest : tOutRequests) {
			OutrequestInfo out = new OutrequestInfo();
			out.getRequestInfo(tOutRequest);
			outrequestInfos.add(out);
		}
		return outrequestInfos;
	}
}
